<template>
    <div class="table-box">
        <XmkTable ref="xmkTable" :columns="columns" :request-api="getTableList" :pagination="false"></XmkTable>
    </div>
</template>
<script setup lang="ts" name="useXmkTable">
import { ColumnProps } from '@/components/XmkTable/interface'
import { getTableDataApi } from '@/api/modules'

const columns = reactive<ColumnProps<any>[]>([
    { type: "selection", fixed: "left", width: 70 },
    { type: "sort", label: "Sort", width: 80 },
    { prop: "id", label: "Id" },
    {
        prop: "name", label: "姓名", search: { el: "input", tooltip: "我是搜索提示" },
    },
    { prop: "gender", label: "性别" },
    { prop: "disable", label: "是否禁用" },
    { prop: "tag", label: "标签" },
])

// 如果你想在请求之前对当前请求参数做一些操作，可以自定义如下函数：params 为当前所有的请求参数（包括分页），最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定	:requestApi="getUserList"
const getTableList = (params: any) => {
    console.log(params)
    // let newParams = JSON.parse(JSON.stringify(params));
    // newParams.createTime && (newParams.startTime = newParams.createTime[0]);
    // newParams.createTime && (newParams.endTime = newParams.createTime[1]);
    // delete newParams.createTime;
    return getTableDataApi()
}
</script>